package com.tocchisu.tv.model;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Manage your own TV-Channel scheduling TV programs with real-world movies and
 * news!
 * 
 * @author elsdev3
 * 
 */
public class DailySchedule extends Entity<DailySchedule> {
  private Date date;
  private List<Slot> slots;
  private final static DateFormat df = new SimpleDateFormat("yyyy/dd/MM hh:mm");

  @Override
  public String toString() {
    String result = "";
    for (Slot slot : slots) {
      result += "[" + df.format(slot.getHourly());
      result += "___" + df.format(slot.getHourly().getNextHourly()) + "]";
      result += " " + slot.getProgram().getName();
      result += "\n";
    }
    return result;
  }

  public List<Slot> getSlots() {
    return slots;
  }

  public void setSlots(List<Slot> slots) {
    this.slots = slots;
  }

  public Date getDate() {
    return date;
  }

  public void setDate(Date date) {
    this.date = date;
  }

  @Override
  public int compareTo(DailySchedule dateToCompare) {
    if (dateToCompare == null || dateToCompare.getDate() == null)
      return -1;
    return date.compareTo(dateToCompare.getDate());
  }

}
